package org.ehe.erp.domain.quality.dto;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 质检看板响应对象
 *
 * @author zhangnn
 * @className QualityDashboardResponse
 * @description 质检管理看板数据，包含各种统计信息
 * @date 2025-09-10 15:00:00
 */
@Data
public class QualityDashboardResponse implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /** 任务统计 */
    private TaskStatistics taskStats;

    /** 质检结果统计 */
    private QualityResultStatistics qualityStats;

    /** 问题统计 */
    private IssueStatistics issueStats;

    /** 超时任务列表 */
    private List<TimeoutTask> timeoutTasks;

    /** 待处理问题列表 */
    private List<PendingIssue> pendingIssues;

    /** 供应商质量排行 */
    private List<SupplierQualityRank> supplierRanks;

    /**
     * 任务统计内部类
     */
    @Data
    public static class TaskStatistics implements Serializable {

        @Serial
        private static final long serialVersionUID = 1L;

        private Integer totalTasks;
        private Integer pendingTasks;
        private Integer inProgressTasks;
        private Integer completedTasks;
        private Integer pausedTasks;
    }

    /**
     * 质检结果统计内部类
     */
    @Data
    public static class QualityResultStatistics implements Serializable {

        @Serial
        private static final long serialVersionUID = 1L;

        private Integer totalCheckedItems;
        private Integer passedItems;
        private Integer failedItems;
        private Double overallPassRate;
        private Map<String, Double> passRateByCategory;
    }

    /**
     * 问题统计内部类
     */
    @Data
    public static class IssueStatistics implements Serializable {

        @Serial
        private static final long serialVersionUID = 1L;

        private Integer totalIssues;
        private Integer pendingIssues;
        private Integer processingIssues;
        private Integer resolvedIssues;
        private Map<Integer, Integer> issuesBySeverity;
        private Map<Integer, Integer> issuesByType;
    }

    /**
     * 超时任务内部类
     */
    @Data
    public static class TimeoutTask implements Serializable {

        @Serial
        private static final long serialVersionUID = 1L;

        private Long taskId;
        private String taskNo;
        private String productName;
        private String assignUserName;
        private Integer overdueDuration; // 超时时长（分钟）
    }

    /**
     * 待处理问题内部类
     */
    @Data
    public static class PendingIssue implements Serializable {

        @Serial
        private static final long serialVersionUID = 1L;

        private Long feedbackId;
        private String feedbackNo;
        private String problemDesc;
        private Integer severityLevel;
        private String feedbackPerson;
        private Integer pendingDuration; // 待处理时长（小时）
    }

    /**
     * 供应商质量排行内部类
     */
    @Data
    public static class SupplierQualityRank implements Serializable {

        @Serial
        private static final long serialVersionUID = 1L;

        private Long supplierId;
        private String supplierName;
        private Integer totalBatches;
        private Integer problemBatches;
        private Double qualityScore; // 质量得分
        private Integer rank; // 排名
    }
}
